#pragma once

#include <services/provider.hpp>




class Application : public QApplication
{
private:

	services::provider::ptr   m_provider;

public:

	Application(int argc, char *argv[]);
	~Application();



	/**
	 * @returns the service provider
	 */
	services::provider::ptr provider() const
	{
		return m_provider;
	}



	/**
	 * Called when a std::exception has been caught.
	 * The application will terminate after this function
	 * has been called, this cannot be changed.
	 *
	 * @param except   the std::exception that has been caught
	 */
	static void onException(const std::exception& except);

	/**
	 * Called when a boost_ext::exception has been caught.
	 * The application will terminate after this function
	 * has been called, this cannot be changed.
	 *
	 * @param except   the boost_ext::exception that has been caught
	 */
	static void onException(const boostext::exception& except);

private:

	/**
	 * Reimplementation of the notify() function.
	 * Used to catch exceptions, thrown in the GUI
	 * thread.
	 * When an exception has been caught, it will be
	 * reported to the user and the application will
	 * exit.
	 * This function only catches boost_ext::exception and
	 * std::exception. All other (non c++) exceptions
	 * will be caught by the exception handler service.
	 */
	bool notify(QObject *receiver, QEvent *event);
};
///////////////////////////////////////////////////////////////////////////////////////////////////
